function pathNew=changeRoot(pathOriginal,pattern) 
%% changeRoot 
% function pathNew=changeRoot(pathOriginal,pattern) 
% Change the root CD 
%
% Given the pathName *pathOriginal*
% Find the beginning of the string *pattern* and 
% Replace all strings to the left of the pattern with those correposponding
% to the current directory 
% AJ 1/17/2012
cucd=pwd; 
pathNew=[]; 
posStart=strfind(pathOriginal,pattern); 
if isempty(posStart) 
    dispaj('Cannot find ',pattern,' in ',pathOriginal); 
    return 
else 
    stringSecond=pathOriginal(posStart:end);
    posSplice=strfind(pwd,pattern);
    if isempty(posSplice)
        dispaj('Cannot find ',pattern,' in ',cucd);
    else
        stringFirst=cucd(1:posSplice-1);        
        pathNew=strcat(stringFirst,stringSecond);
    end
end 